
<script language="javascript">
{literal}
	var fixHelper1 = function(e, ui) {
		ui.children('.maintr1').children().each(function() {
			$(this).width($(this).width());
		});
		return ui;
	};
{/literal}

$(document).ready(function() {ldelim}	
	$("form[name='sort']").submit(function() {ldelim}
		var url = $(this).attr('action');
		var data = $(this).serialize();	
			execute('', '', 'Товары отсортированы', url, '', data, '', $('#tab4').find('.tab_container'));
		return false;
	{rdelim});



		$('input[type="text"]').mousedown(function(e){ldelim}e.stopPropagation();{rdelim});
	
{rdelim});


$(function(){ldelim}
    $("#sort_product").sortable({ldelim}
    	opacity: 0.6,
    	helper: fixHelper1, 
    	'start': function (event, ui){ldelim}
    	        ui.placeholder.html("<tr><td colspan='14' style='height:38px;'>&nbsp;</td></tr>");
    	{rdelim},
    	cancel: ".disabled",
    	'update': function(event,ui)
    	        {ldelim}
    	          	var order = $("#sort_product").sortable('serialize');
    	          	$('#AjaxResult').load("index.php?do=modules&action=modedit&mod=shop&moduleaction=products&cp={$sess}&sub=savepos&page={$smarty.request.page}&recordset={$smarty.request.recordset}&"+order);
    	       {rdelim}
    {rdelim}).disableSelection();
{rdelim});
</script>
{strip}
<br/>
{*
<div class="topleftDir head opened" style="border-top:1px solid #D5D5D5;" title="нажмите что бы развернуть или свернуть"><h5>Сортировка товаров</h5></div>
*}
<div class="head {if $smarty.request.block_sort != '1'}closed{/if}" style="border-top:1px solid #D5D5D5;"><h5>Сортировка товаров</h5></div>

<div>

	<form name="sort" method="post" action="index.php?do=modules&action=modedit&mod=shop&moduleaction=products&cp={$sess}" class="mainForm">
	<input type="hidden" name="block_sort" value="1">
		<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
			<tr>
				<td width="150">{#ProductSArtTitle#}</td>

				<td width="250">
					<input style="width:150px" name="product_query" type="text" value="{$smarty.request.product_query|stripslashes|escape}" />
				</td>

				<td width="150">{#PriceFromTo#}</td>

				<td width="250">
					<input style="width:70px" type="text" name="product_price_start" value="{$smarty.request.product_price_start|stripslashes|escape|default:'0.00'}" />
					<input style="width:70px" type="text" name="product_price_end" value="{$smarty.request.product_price_end|stripslashes|escape|default:'100000.00'}" />
				</td>
			</tr>

			<tr>
				<td>{#ManufacturerS#}</td>
				<td>
					<select style="width:150px" name="product_manufacturer">
						<option value="">{#ManufacturerA#}</option>
						{foreach from=$Manufacturer item=m}
							<option value="{$m->Id}" {if $smarty.request.product_manufacturer==$m->Id}selected="selected"{/if}>{$m->Name|stripslashes}</option>
						{/foreach}
					</select>
				</td>


				<td>{#ProductStore#}</td>
				<td>
					<select style="width:150px" name="product_warehouse">
						<option value="egal">{#ProductDm#}</option>
						{section name='product_warehouse' loop=210 step=10 start=10}
							<option value="{$smarty.section.product_warehouse.index}" {if $smarty.request.product_warehouse==$smarty.section.product_warehouse.index}selected="selected"{/if}>{#ProductStoreS#} {$smarty.section.product_warehouse.index}</option>
						{/section}
					</select>
				</td>
			</tr>

			<tr>
				<td>{#ProductCategs#}</td>

				<td>
					<select style="width:150px" name="product_category">
						<option value="">{#ProductCategsAll#}</option>
						{foreach from=$ProductCategs item=pc}
							<option value="{$pc->Id}"{if $pc->Id==$smarty.request.product_category} selected="selected"{/if}>{$pc->expander}{$pc->category_name|escape:html|stripslashes}</option>
						{/foreach}
					</select>
				</td>

				<td>{#ProductBought#}</td>

				<td>
					<select style="width:150px" name="product_sales">
						<option value="egal">{#ProductDm#}</option>
						{section name='product_sales' loop=210 step=10 start=10}
							<option value="{$smarty.section.product_sales.index}"{if $smarty.request.product_sales==$smarty.section.product_sales.index} selected="selected"{/if}>{#ProductStoreS#} {$smarty.section.product_sales.index}</option>
						{/section}
					</select>
				</td>
			</tr>

			<tr>
				<td>{#ProductActiveSearch#}</td>

				<td>
					<select style="width:150px" name="product_active">
						<option value="all"{if $smarty.request.product_active=='all'} selected="selected"{/if}>{#ProductActiveSearchAll#}</option>
						<option value="1"{if $smarty.request.product_active=='1'} selected="selected"{/if}>{#ProductActiveSearchA#}</option>
						<option value="0"{if $smarty.request.product_active=='0'} selected="selected"{/if}>{#ProductActiveSearchI#}</option>
					</select>
				</td>

				<td>{#ProductDataSReduced#}</td>

				<td>
					<select name="recordset" style="width:60px">
						{section name=recordset loop=110 step=10 start=10}
						{*{if $smarty.section.recordset.index == $smarty.request.recordset|default:10} selected=selected"{/if}*}
							<option value="{$smarty.section.recordset.index}" {if $smarty.request.recordset==$smarty.section.recordset.index} selected="selected"{/if}>{$smarty.section.recordset.index}</option>
						{/section}
					</select>

					<label>на страницу</label>
				</td>
			</tr>
			
			<tr>
				<td>Сортировать по:</td>

				<td>
					<select style="width:150px" name="sort">
						<option value="">по Умолчанию</option>
						<option value="product_name_ASC"{if $smarty.request.sort=='product_name_ASC'} selected="selected"{/if}>Наименованию ↑</option>
						<option value="product_name_DESC"{if $smarty.request.sort=='product_name_DESC'} selected="selected"{/if}>Наименованию ↓</option>
						<option value="product_price_ASC"{if $smarty.request.sort=='product_price_ASC'} selected="selected"{/if}>Цене ↑</option>
						<option value="product_price_DESC"{if $smarty.request.sort=='product_price_DESC'} selected="selected"{/if}>Цене ↓</option>
						<option value="product_sales_ASC"{if $smarty.request.sort=='product_sales_ASC'} selected="selected"{/if}>Кол-ву продаж ↑</option>
						<option value="product_sales_DESC"{if $smarty.request.sort=='product_sales_DESC'} selected="selected"{/if}>Кол-ву продаж ↓</option>
					</select>
				</td>

				<td>Показать только</td>

				<td>
					<select style="width:120px;" name="product_status">
						<option value="">Показывать все</option>
						<option value=""{if $smarty.request.product_status==''} selected="selected"{/if}>Новинки</option>
						<option value=""{if $smarty.request.product_status==''} selected="selected"{/if}>Распродажа</option>
						<option value=""{if $smarty.request.product_status==''} selected="selected"{/if}>Топ</option>
					</select>
				</td>
			</tr>			
		</table>
		{*<input type="hidden" name="page" value="{$smarty.request.page}" />*}
		<div class="rowElem"><input type="submit" class="basicBtn topDir" value="Сортировать" /></div>
	</form>
</div>



<br/>
<h4>Список существующих товаров</h4>
	{if $page_nav}
	<div class="pagination">
	<ul class="pages">
		{$page_nav}
	</ul>
	</div>
	{/if}
{if $products}	
<div id="AjaxResult"></div>
<form name="kform" action="index.php?do=modules&action=modedit&mod=shop&moduleaction=products&cp={$sess}&sub=save" method="post" class="mainForm mainForm2">
	<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
		<thead>
		<tr>
			<td class="tableheader"><center><input name="allbox" type="checkbox" id="d" onclick="selall();" value="" /></center></td>
			<td class="tableheader">id</td>
			<td class="tableheader">&nbsp;</td>
			<td class="tableheader"><a class="header" href="index.php?do=modules&action=modedit&mod=shop&moduleaction=products&cp={$sess}&recordset={$smarty.request.recordset|default:10}&sort={if $smarty.request.sort=='NameAsc'}NameDesc{else}NameAsc{/if}">{#CatName#}</a></td>
			<td class="tableheader"><a class="header" href="index.php?do=modules&action=modedit&mod=shop&moduleaction=products&cp={$sess}&recordset={$smarty.request.recordset|default:10}&sort={if $smarty.request.sort=='PriceAsc'}PriceDesc{else}PriceAsc{/if}">{#ProductPrice#}</a></td>
			<td class="tableheader" align="center">Есть</td>
			<td class="tableheader" align="center">Всего</td>
			<td class="tableheader">Ушло</td>
			<td class="tableheader">{#CatIn#}</td>
			<td class="tableheader">{#ProductPosition#}</td>
			<td class="tableheader" width="1%" align="center" colspan="4">{#Actions#}</td>
		</tr>
		</thead>
		<tbody id="sort_product">
		{foreach from=$products item=i}
			<tr id="item_{$i->Id}" style="cursor:move;" class="maintr1">

				<td width="1%">
					<input type="checkbox" name="shopartikel_{$i->Id}" value="1" />
				</td>
				<td width="1%">
					<small>{$i->Id}</small>
				</td>
				<td width="40" style="height:40px">
					{if $i->BildFehler==1}
						&nbsp;
					{else}
						<a href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=shop&moduleaction=edit_product&cp={$sess}&pop=1&Id={$i->Id}','980','650','1','shopshipper');">
							<img src="{$i->product_image_thumb}" alt="" border="0" />
						</a>
					{/if}
				</td>

				<td>
					{if $i->product_active==1}
						<a title="{#ProductEdit#}" href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=shop&moduleaction=edit_product&cp={$sess}&pop=1&Id={$i->Id}','980','740','1','edit_product');">
						{$i->product_name|truncate:65|stripslashes|escape}</a>
					{else}
						<span style="text-decoration:line-through">{$i->product_name|truncate:65|stripslashes|escape}</span>
					{/if}
					<br />
					<small>{#ProductNr#} {$i->product_article}</small>
				</td>

				<td width="1%" align="center">
					<input name="product_price[{$i->Id}]" type="text" style="width:50px" maxlength="10" value="{$i->product_price}" />
				</td>

				<td width="25" align="center" nowrap>
					{$i->ostatok}
					{if $i->ostatok < 1 && $i->wish > 0}
						<br/>
						<small>хотят {$i->wish}</small>
					{/if}
				</td>

				<td width="25" align="center">
					{$i->product_warehouse}
				</td>

				<td width="25" align="center">
					{*{$i->Bestellungen}*}
					{$i->product_reserve}
				</td>

				<td width="110">
				Основная<br/>
				&nbsp;&nbsp;&nbsp;<small class="nostyle">{$i->maincateg}</small><br/>
				Дополнительно:
				{foreach from=$i->product_category_multi_parse item=multi}
					&nbsp;&nbsp;&nbsp;<small class="nostyle">{$multi.category_name}</small>
				{/foreach}
				{*
					{if $smarty.request.product_category == $multi.category_id}style="background-color:#ffff00;"{/if}
					<select name="product_category[{$i->Id}]">
						{foreach from=$ProductCategs item=pc}
							<option value="{$pc->Id}" {if $pc->Id==$i->product_category}selected="selected"{/if}>{$pc->expander}{$pc->category_name|escape:html|stripslashes}</option>
						{/foreach}
					</select>
					
					
					убрал пока так как jqTransform очень сильно грузит окно при выводе большого кол-ва товаров
					
					
					categ name
					
					
					
					*}
				</td>

				<td width="15"><input name="PosiStartseite[{$i->Id}]" type="text" style="width:20px" maxlength="12" value="{$i->PosiStartseite}" /></td>

				<td width="1%">
					<a class="topleftDir icon_sprite ico_edit" title="Редактировать товар" onclick="updateHash('tab4-2tab'); setupHash('widget2', this);" href="#tab4-2" 
								rel="index.php?do=modules&action=modedit&mod=shop&moduleaction=edit_product&cp={$sess}&pop=1&Id={$i->Id}"></a>
					
					
				</td>

				<td width="1%">
					
					<a class="topleftDir icon_sprite ico_setting" title="Редактировать дополнительные свойства товара<br/><br/>Устанавливаются в зависимости от категории размещения товара.<br/><br/>Свойства категории редактируются в разделе 'Категории' -> 'Свойства категрий'" onclick="updateHash('tab4-2tab'); setupHash('widget2', this);" href="#tab4-2" 
								rel="index.php?do=modules&action=modedit&mod=shop&moduleaction=edit_product&cp={$sess}&pop=1&Id={$i->Id}"></a>
					
					
					
				</td>

				<td width="1%">
					<a class="topleftDir icon_sprite ico_query" title="{#PriceSt#}" title="{#DOC_TEMPORARY_DELETE#}"></a>
					
				</td>
{* убрал - тк как не уверен что это вообще нужно нам
				<td width="1%">
					<a title="{#EditEsdDownloads#}" href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=shop&moduleaction=esd_downloads&cp={$sess}&pop=1&Id={$i->Id}&KatId={$i->KatId}','980','740','1','edit_vars');">
					<img src="{$tpl_dir}/images/icon_esd_download.gif" alt="" border="0" /></a>
				</td>
*}


				<td width="1%">
					{if $i->comments > 0}
						{*<a title="{#EditCommentsR#}" href="javascript:void(0);" onclick="cp_pop('index.php?do=modules&action=modedit&mod=shop&moduleaction=edit_comments&cp={$sess}&pop=1&Id={$i->Id}','980','740','1','edit_comments');"></a>*}
						<a class="topleftDir icon_sprite ico_comment_no" title="{#EditCommentsR#}"></a>
					{else}
						<a class="topleftDir icon_sprite ico_blanc" title="Комментарии отсутствуют"></a>
					{/if}
				</td>
			</tr>
		{/foreach}
{*	убрал - неохота сейчас это делать	
		<tr class="mainForm disabled">
			<td colspan="3">
				{#ProductMarkedAction#}
			</td>
			<td colspan="7">
				<select name="SubAction">
					<option value="nothing">---</option>
					<option value="close">{#ProductClose#}</option>
					<option value="open">{#ProductOpen#}</option>
					<option value="nothing"></option>
					<option value="del">{#ProductMassDelete#}</option>
				</select>
			</td>
			<td colspan="4">
				<input class="basicBtn topDir" type="submit" value="{#ProductSave#}" />
			</td>
		</tr>
*}		
	</tbody>
	</table>
	<div class="rowElem" style="padding:0px"></div>
</form>
{else}
		<ul class="messages">
			<li class="highlight yellow">Товары не найдены<br/><br/>Если вы воспользовались сортировкой, то попробуйте изменить условия на более мягкие</li>
		</ul>
{/if}

	{if $page_nav}
	<div class="pagination">
	<ul class="pages">
		{$page_nav}
	</ul>
	</div>
	{/if}
	<br />
	
<br />
{/strip}